
cc.Class({
    extends: require('wy-Component'),

    properties: {
        layout: cc.Layout,
    },


    onBindEvent() {
        global.Event.on('BANNER_RESIZE', this._resizeLayout.bind(this), this);
    },

    offBindEvent() {
        global.Event.off('BANNER_RESIZE', this._resizeLayout.bind(this), this);
    },

    _resizeLayout(height) {
        this.node.height = height;
        this.layout && this.layout.updateLayout();
    },

    init() {
        let height = global.BannerAD.getBannerADHeight();
        this.onBindEvent();
        this._resizeLayout(height);
    },

    onDestroy() {
        this.offBindEvent();
    },

    onEnable() {
        CC_WECHATGAME && this.init();
    },

    onDisable() {
        this.offBindEvent();
    },

});
